<template>
	<div class="box">
		<div class="title">调试度目设备</div>
		<div class="box">
			<el-form :model="form" label-width="200px">
				<el-form-item label="设备ID">
					<el-input v-model="form.uuid"></el-input>
				</el-form-item>
				<el-form-item label="设备密码">
					<el-input v-model="form.pass"></el-input>
				</el-form-item>
				<el-form-item label="指令">
					<el-select v-model="form.command" @change="changeCommand">
						<el-option v-for="item in commandList" :key="item.value" :label="item.label"
							:value="item.value"></el-option>
					</el-select>
				</el-form-item>
				<!-- 发送密码 -->
				<div v-if="form.command === 'setPassword' ">
					<el-form-item label="旧密码">
						<el-input v-model="form.old_password"></el-input>
					</el-form-item>
					<el-form-item label="新密码">
						<el-input v-model="form.new_password"></el-input>
					</el-form-item>
				</div>

				<!-- 发送识别方式 -->
				<div v-if="form.command === 'setBootupRegMethod' ">
					<el-form-item label="默认识别方式">
						<el-radio-group v-model="form.reg_method">
							<el-radio label="Default">Default</el-radio>
							<el-radio label="Gate">Gate</el-radio>
							<el-radio label="Attendance">Attendance</el-radio>
							<el-radio label="Finance">Finance</el-radio>
						</el-radio-group>
					</el-form-item>
				</div>
				<!-- 发送删除 -->
				<div v-if="form.command === 'deleteUser' ">
					<el-form-item label="USER_ID">
						<el-input v-model="form.user_id"></el-input>
					</el-form-item>
				</div>
				<!-- 发送添加 -->
				<div v-if="form.command === 'addUser' ">
					<el-form-item label="名称">
						<el-input v-model="form.name"></el-input>
					</el-form-item>
					<el-form-item label="USER_ID">
						<el-input v-model="form.user_id"></el-input>
					</el-form-item>
					<el-form-item label="照片类型">
						<el-input v-model="form.image_type"></el-input>
					</el-form-item>
					<el-form-item label="上传照片">
						<el-upload action="https://upload-z2.qiniup.com" ref="upload" :limit="1"
							:before-upload="beforeAvatarUpload" :auto-upload="false" :on-success="handleAvatarSuccess"
							:on-remove="handleRemove" :on-exceed="handleExceed" :on-change="handleChange"
							:data="imgData">
							<el-button size="small" type="primary">选择图片</el-button>
						</el-upload>
						<div v-if="hasNewImage" style="color: red; font-size: 12px;">* 点击文件名可删除所选图片</div>
						<div class="up-img" v-if="form.image_content">
							<span style="display: flex;justify-items: center;color: #67C23A;"></span>
							<img class="pic-box" :src="form.image_content" />
						</div>
						<div class="up-img" v-else>
							<img class="pic-box" :src="change_href" />
						</div>
					</el-form-item>
				</div>
				<!-- 发送获取 -->
				<div v-if="form.command === 'getUserList' ">
					<el-form-item label="起始">
						<el-input v-model="form.start"></el-input>
					</el-form-item>
					<el-form-item label="长度">
						<el-input v-model="form.length"></el-input>
					</el-form-item>
				</div>
				<!-- 活体类型 -->
				<div v-if="form.command === 'setLivenessType' ">
					<el-form-item label="活体类型">
						<el-radio-group v-model="form.liveness_type">
							<el-radio label="NONE">NONE</el-radio>
							<el-radio :label="RGB">RGB</el-radio>
							<el-radio :label="NIR">NIR</el-radio>
							<el-radio :label="'RGB+NIR'">RGB+NIR</el-radio>
							<el-radio label="RGB+Depth">RGB+Depth</el-radio>
							<el-radio label="RGB+NIR+Depth">RGB+NIR+Depth</el-radio>
						</el-radio-group>
					</el-form-item>
				</div>
				<!-- 发送质量控制 -->
				<div v-if="form.command === 'setQualityControl' ">
					<el-form-item label="流程">
						<el-radio-group v-model="form.work_field">
							<el-radio label="ALL">ALL</el-radio>
							<el-radio label="ADDUSER">ADDUSER</el-radio>
							<el-radio label="RECOGNITION">RECOGNITION</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="质量控制">
						<el-radio-group v-model="form.quality_control">
							<el-radio label="NONE">NONE</el-radio>
							<el-radio label="LOW">LOW</el-radio>
							<el-radio label="NORMAL">NORMAL</el-radio>
							<el-radio label="HIGH">HIGH</el-radio>
						</el-radio-group>
					</el-form-item>
				</div>
				<!-- 间隔时间毫秒 -->
				<div v-if="form.command === 'setIntervalTime' ">
					<el-form-item label="间隔时间毫秒">
						<el-input v-model="form.time"></el-input>
					</el-form-item>
				</div>
				<!-- 固件升级 -->
				<div v-if="form.command === 'upgrade' ">
					<el-form-item label="固件地址">
						<el-input v-model="form.url"></el-input>
					</el-form-item>
				</div>
				<!-- 设置有线网络 -->
				<div v-if="form.command === 'setWiredNetwork' ">
					<el-form-item label="是否开启DHCP">
						<el-switch v-model="form.DHCP" active-color="#2a9f93">
						</el-switch>
					</el-form-item>
					<el-form-item label="手动DNS">
						<el-radio-group v-model="form.manual_dns">
							<el-radio :label="0">否</el-radio>
							<el-radio :label="1">是</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="DNS2" v-if="manualDns">
						<el-input v-model="form.DNS2"></el-input>
					</el-form-item>
					<el-form-item label="ip地址">
						<el-input v-model="form.IP"></el-input>
					</el-form-item>
					<el-form-item label="网关">
						<el-input v-model="form.gateway"></el-input>
					</el-form-item>
					<el-form-item label="子网掩码">
						<el-input v-model="form.subnet_mask"></el-input>
					</el-form-item>
					<el-form-item label="DNS">
						<el-input v-model="form.DNS"></el-input>
					</el-form-item>
				</div>
	

				<!-- 屏保 -->
				<div v-if="form.command === 'setScreenSave' ">
					<el-form-item label="命令ID">
						<el-input v-model="form.request_id"></el-input>
					</el-form-item>
					<el-form-item label="启用屏保功能">
						<el-radio-group v-model="form.enable">
							<el-radio :label="0">否</el-radio>
							<el-radio :label="1">启用</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="识别人脸到人脸后是否保持屏保模式">
						<el-radio-group v-model="form.stay">
							<el-radio :label="0">关闭屏保显示实时画面</el-radio>
							<el-radio :label="1">不关闭屏保，继续显示屏保</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="每天屏保时间段">
						<el-time-picker is-range v-model="screenTime" range-separator="至" start-placeholder="屏保开始时间"
							end-placeholder="屏保结束时间" placeholder="选择时间范围" :value-format="timeScreen"
							@change="screenTimeChange">
						</el-time-picker>
					</el-form-item>
					<el-form-item label="图片切换间隔时间">
						<el-input-number v-model="form.interval_time"></el-input-number>
					</el-form-item>
					<el-form-item label="人离开后进入屏保的时间">
						<el-input-number v-model="form.start_time"></el-input-number>
					</el-form-item>
					<el-form-item label="屏保照片">
						<el-input v-model="form.image_1" placeholder="图片地址一" style="margin-bottom: 10px;"></el-input>
						<el-input v-model="form.image_2" placeholder="图片地址二" style="margin-bottom: 10px;"></el-input>
						<el-input v-model="form.image_3" placeholder="图片地址三" style="margin-bottom: 10px;"></el-input>
						<el-input v-model="form.image_4" placeholder="图片地址四" style="margin-bottom: 10px;"></el-input>
						<el-input v-model="form.image_5" placeholder="图片地址五" style="margin-bottom: 10px;"></el-input>
					</el-form-item>
				</div>
				<!-- 断点续传 -->
				<div v-if="form.command === 'setResumeTransfer' ">
					<el-form-item label="是否启用">
						<el-radio-group v-model="form.enable">
							<el-radio :label="0">否</el-radio>
							<el-radio :label="1">启用</el-radio>
						</el-radio-group>
					</el-form-item>
				</div>
				<!-- 设置 ntp服务器  -->
				<div v-if="form.command === 'setNtpServer' ">
					<el-form-item label="ntp服务器">
						<el-input v-model="form.ntp_server"></el-input>
					</el-form-item>
				</div>
				<!-- 获取日志  -->
				<div v-if="form.command === 'getLogFile' ">
					<el-form-item label="日志名">
						<el-input v-model="form.log_name"></el-input>
					</el-form-item>
				</div>
				<!-- 设置服务器地址  -->
				<div v-if="form.command === 'setPlatformServer' ">
					<el-form-item label="http服务器">
						<el-input v-model="form.serverAddr"></el-input>
					</el-form-item>
					<el-form-item label="ws服务器">
						<el-input v-model="form.wsServerAddr"></el-input>
					</el-form-item>
				</div>
				<!-- 设置显示参数  -->
				<div v-if="form.command === 'SetFaceConfig' ">
					<el-form-item label="命令ID">
						<el-input v-model="form.request_id"></el-input>
					</el-form-item>
					<el-form-item label="比对阀值">
						<el-input-number v-model="form.CmpThreshold"></el-input-number>
					</el-form-item>
					<el-form-item label="屏幕显示模式">
						<el-radio-group v-model="form.LcdShowMode">
							<el-radio :label="0">无人时关闭屏幕</el-radio>
							<el-radio :label="1">一直打开屏幕</el-radio>
							<el-radio :label="2">无人时屏保</el-radio>
							<el-radio :label="3">总是屏保</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="补光灯控制">
						<el-radio-group v-model="form.LedMode">
							<el-radio :label="0">关闭补光灯</el-radio>
							<el-radio :label="1">有人时打开</el-radio>
							<el-radio :label="2">移动侦测控制</el-radio>
							<el-radio :label="3">按时间控制</el-radio>
							<el-radio :label="4">时间+人脸控制</el-radio>
							<el-radio :label="5">时间+移动侦测控制</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="补光灯时间">
						<el-time-picker is-range v-model="ledDayTime" range-separator="至" start-placeholder="补光灯关闭开始时间"
							end-placeholder="补光灯关闭结束时间" placeholder="选择时间范围" :value-format="ledDayTimeFormat"
							@change="ledDayTimeChange">
						</el-time-picker>
					</el-form-item>
				</div>
				<div style="margin: 20px; text-align: right;">
					<el-button type="primary" @click="debugPost">提交</el-button>
				</div>
			</el-form>
		</div>

	</div>
</template>

<script>
	import md5 from "blueimp-md5";
	var Qs = require('qs')
	export default {
		data() {
			return {
				imgData: {
					key: "",
					token: ""
				},
				fileName: "",
				suffix: "",
				qiniuaddr: "http://tu.fengniaotuangou.cn", // 七牛云图片外链地址
				old_href: "", // 原人脸图片
				change_href: "",
				hasNewImage: false,
				new_file: "",
				form: {
					// 公共参数
					uuid: '',
					pass: '',
					// 指令
					command: '',
					// 发送密码
					old_password: '',
					new_password: '',
					// 发送识别方式
					reg_method: '',
					// 删除USER/添加USER
					user_id: '',
					image_content: '',
					image_type: 'URL',
					name: '',
					// 获取USER列表
					start: '',
					length: '',
					// 活体类型
					liveness_type: '',
					// 发现质量控制
					work_field: '',
					quality_control: '',
					// 间隔时间毫秒
					time: '',
					// 固件升级地址
					url: '',
					// 设置有限网络
					DHCP: false,
					manual_dns: 0,
					DNS2: '',
					IP: '',
					gateway: '',
					subnet_mask: '',
					DNS: '',
					// 设置屏保
					request_id: '',
					enable: 0,
					stay: 0,
					display_time: '',
					interval_time: 0,
					start_time: 0,
					image_1: '',
					image_2: '',
					image_3: '',
					image_4: '',
					image_5: '',
					//设置ntp服务器
					ntp_server: '',
					// 日志名
					log_name: '',
					// 服务器地址
					serverAddr: '',
					wsServerAddr: '',
					// 设置显示参数
					CmpThreshold: 0,
					LcdShowMode: 0,
					LedMode: 0,
					LedDayTimeH: 0,
					LedDayTimeM: 0,
					LedDayTimeS: 0,
					LedNightTimeH: 0,
					LedNightTimeM: 0,
					LedNightTimeS: 0,
				},
				ledDayTime: '', // 补光灯时间
				ledDayTimeFormat: 'HH:mm:ss',
				// 屏保开始时间
				screenTime: '',
				timeScreen: 'HH:mm', // 时间格式
				commandList: [{
						value: 'setPassword',
						label: '发送密码'
					},
					{
						value: 'setBootupRegMethod',
						label: '发送识别方式'
					},
					{
						value: 'deleteUser',
						label: '删除USER'
					},
					{
						value: 'addUser',
						label: '添加USER'
					},
					{
						value: 'getUserList',
						label: '获取USER列表'
					},
					{
						value: 'setLivenessType',
						label: '活体类型'
					},
					{
						value: 'setQualityControl',
						label: '发送质量控制'
					},
					{
						value: 'setIntervalTime',
						label: '间隔时间毫秒'
					},
					{
						value: 'getSoftVersion',
						label: '获取软件版本'
					},
					{
						value: 'upgrade',
						label: '固件升级'
					},
					{
						value: 'setWiredNetwork',
						label: '设置有线网络'
					},
					{
						value: 'getWiredNetwork',
						label: '获取有线网络设置'
					},
					{
						value: 'openDoor',
						label: '开门'
					},
					{
						value: 'setScreenSave',
						label: '设置屏保'
					},
					{
						value: 'setResumeTransfer',
						label: '设置断网续传'
					},
					{
						value: 'setNtpServer',
						label: '设置ntp服务器'
					},
					{
						value: 'getLogFile',
						label: ' 获取日志'
					},
					{
						value: 'setPlatformServer',
						label: ' 设置服务器地址'
					},
					{
						value: 'SetFaceConfig',
						label: ' 设置显示参数'
					},
					{
						value: 'restart',
						label: ' 重启'
					}
				]
			}
		},
		mounted() {
			// this.debugPost()
			this.getQiniuToken()
		},
		methods: {
			screenTimeChange(val) {
				var self = this;
				self.form.display_time = val[0] + '-' + val[1];
			},
			ledDayTimeChange(val) {
				var self = this;
				self.form.LedDayTimeH = val[0].slice(0, 2);
				self.form.LedDayTimeM = val[0].slice(3, 5);
				self.form.LedDayTimeS = val[0].slice(6, 8);
				self.form.LedNightTimeH = val[1].slice(0, 2);
				self.form.LedNightTimeM = val[1].slice(3, 5);
				self.form.LedNightTimeS = val[1].slice(6, 8)
			},
			resetForm() {
				var self = this;
				// 发送密码
				self.form.old_password = '';
				self.form.new_password = '';
				// 发送识别方式
				self.form.reg_method = '';
				// 删除USER/添加USER
				self.form.user_id = '';
				self.form.image_content = '';
				self.form.image_type = 'URL';
				self.form.name = '';
				// 获取USER列表
				self.form.start = '';
				self.form.length = '';
				// 活体类型
				self.form.liveness_type = '';
				// 发现质量控制
				self.form.work_field = '';
				self.form.quality_control = '';
				// 间隔时间毫秒
				self.form.time = '';
				// 固件升级地址
				self.form.url = '';
				// 设置有限网络
				self.form.DHCP = false;
				self.form.manual_dns = 0;
				self.form.DNS2 = '';
				self.form.IP = '';
				self.form.gateway = '';
				self.form.subnet_mask = '';
				self.form.DNS = '';
				// 设置屏保
				self.form.request_id = '';
				self.form.enable = 0;
				self.form.stay = 0;
				self.form.display_time = '';
				self.form.interval_time = 1;
				self.form.start_time = 1;
				self.form.image_1 = '';
				self.form.image_2 = '';
				self.form.image_3 = ''
				self.form.image_4 = '';
				self.form.image_5 = '';
				//设置ntp服务器
				self.form.ntp_server = '';
				// 日志名
				self.form.log_name = '';
				// 服务器地址
				self.form.serverAddr = '';
				self.form.wsServerAddr = '';
				// 设置显示参数
				self.form.CmpThreshold = 0;
				self.form.LcdShowMode = 0;
				self.form.LedMode = 0;
				self.form.LedDayTimeH = 0;
				self.form.LedDayTimeM = 0;
				self.form.LedDayTimeS = 0;
				self.form.LedNightTimeH = 0;
				self.form.LedNightTimeM = 0;
				self.form.LedNightTimeS = 0;
			},
			resetForm2() {
				var self = this;
				self.form.uuid = '';
				self.form.pass = '';
				// 发送密码
				self.form.old_password = '';
				self.form.new_password = '';
				// 发送识别方式
				self.form.reg_method = '';
				// 删除USER/添加USER
				self.form.user_id = '';
				self.form.image_content = '';
				self.form.image_type = 'URL';
				self.form.name = '';
				// 获取USER列表
				self.form.start = '';
				self.form.length = '';
				// 活体类型
				self.form.liveness_type = '';
				// 发现质量控制
				self.form.work_field = '';
				self.form.quality_control = '';
				// 间隔时间毫秒
				self.form.time = '';
				// 固件升级地址
				self.form.url = '';
				// 设置有限网络
				self.form.DHCP = false;
				self.form.manual_dns = 0;
				self.form.DNS2 = '';
				self.form.IP = '';
				self.form.gateway = '';
				self.form.subnet_mask = '';
				self.form.DNS = '';
				// 设置屏保
				self.form.request_id = '';
				self.form.enable = 0;
				self.form.stay = 0;
				self.form.display_time = '';
				self.form.interval_time = 1;
				self.form.start_time = 1;
				self.form.image_1 = '';
				self.form.image_2 = '';
				self.form.image_3 = ''
				self.form.image_4 = '';
				self.form.image_5 = '';
				//设置ntp服务器
				self.form.ntp_server = '';
				// 日志名
				self.form.log_name = '';
				// 服务器地址
				self.form.serverAddr = '';
				self.form.wsServerAddr = '';
				// 设置显示参数
				self.form.CmpThreshold = 0;
				self.form.LcdShowMode = 0;
				self.form.LedMode = 0;
				self.form.LedDayTimeH = 0;
				self.form.LedDayTimeM = 0;
				self.form.LedDayTimeS = 0;
				self.form.LedNightTimeH = 0;
				self.form.LedNightTimeM = 0;
				self.form.LedNightTimeS = 0;
			},
			changeCommand() {
				var self = this;
				self.resetForm();
			},
			debugPost() {
				var self = this;
				let form = 'form' + self.form.command;
				switch (self.form.command) {
					case 'setPassword':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							old_password: self.form.old_password,
							new_password: self.form.new_password,
						})
						self.postDebugDevice(form);
						break;
					case 'setBootupRegMethod':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							reg_method: self.form.reg_method,
						})
						self.postDebugDevice(form);
						break;
					case 'deleteUser':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							user_id: self.form.user_id,
						})
						self.postDebugDevice(form);
						break;
					case 'getUserList':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							start: self.form.start,
							length: self.form.length,
						})
						self.postDebugDevice(form);
						break;
					case 'setLivenessType':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							liveness_type: self.form.liveness_type
						})
						self.postDebugDevice(form);
						break;
					case 'setQualityControl':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							work_field: self.form.work_field,
							quality_control: self.form.quality_control,
						})
						self.postDebugDevice(form);
						break;
					case 'setIntervalTime':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							time: self.form.time
						})
						self.postDebugDevice(form);
						break;
					case 'upgrade':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							url: self.form.url
						})
						self.postDebugDevice(form);
						break;
					case 'setWiredNetwork':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							DHCP: self.form.DHCP,
							IP: self.form.IP,
							gateway: self.form.gateway,
							subnet_mask: self.form.subnet_mask,
							DNS: self.form.DNS,
						})
						self.postDebugDevice(form);
						break;
					case 'addUser':
						if (self.change_href === "") {
							var form9 = Qs.stringify({
								uuid: self.form.uuid,
								command: self.form.command,
								name: self.form.name,
								user_id: self.form.user_id,
								image_type: self.form.image_type,
								image_content: self.form.image_content,
								pass: self.form.pass
							})
							self.postDebugDevice(form);
						} else {
							this.$refs.upload.submit();
						}
						break;
					case 'setScreenSave':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							request_id: self.form.request_id,
							enable: self.form.enable,
							stay: self.form.stay,
							display_time: self.form.display_time,
							interval_time: self.form.interval_time,
							start_time: self.form.start_time,
							image_1: self.form.image_1,
							image_2: self.form.image_2,
							image_3: self.form.image_3,
							image_4: self.form.image_4,
							image_5: self.form.image_5,
						})
						self.postDebugDevice(form);
						break;
					case 'setResumeTransfer':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							enable: self.form.enable,
						})
						self.postDebugDevice(form);
						break;
					case 'setNtpServer':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							ntp_server: self.form.ntp_server,
						})
						self.postDebugDevice(form);
						break;
					case 'getLogFile':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							log_name: self.form.log_name,
						})
						self.postDebugDevice(form);
						break;
					case 'setPlatformServer':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							serverAddr: self.form.serverAddr,
							wsServerAddr: self.form.wsServerAddr,
						})
						self.postDebugDevice(form);
						break;
					case 'SetFaceConfig':
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
							request_id: self.form.request_id,
							CmpThreshold: self.form.CmpThreshold,
							LcdShowMode: self.form.LcdShowMode,
							LedMode: self.form.LedMode,
							LedDayTimeH: self.form.LedDayTimeH,
							LedDayTimeM: self.form.LedDayTimeM,
							LedDayTimeS: self.form.LedDayTimeS,
							LedNightTimeH: self.form.LedNightTimeH,
							LedNightTimeM: self.form.LedNightTimeM,
							LedNightTimeS: self.form.LedNightTimeS,
						})
						self.postDebugDevice(form);
						break;
					default:
						form = Qs.stringify({
							uuid: self.form.uuid,
							command: self.form.command,
							pass: self.form.pass,
						})
						self.postDebugDevice(form);
						break;
				}
			},
			// 请求
			postDebugDevice(val) {
				var self = this;
				this.$axios.post('https://api.fengniaotuangou.cn/api/debug/device', val).then(res => {
					self.$message.success('发送成功');
					seld.resetForm2();
				});
			},


			// 人脸信息
			handleChange(file) {
				var self = this;
				self.change_href = URL.createObjectURL(file.raw);
				self.hasNewImage = true;
			},
			handleRemove(file) {
				var self = this;
				self.change_href = "";
				self.hasNewImage = false;
			},
			beforeAvatarUpload(file) {
				var self = this;
				// self.familyForm.href = file.name;
				self.fileName = md5(file.name);
				self.suffix = file.name.substring(file.name.lastIndexOf(".") + 1);
				self.imgData.key = `tmp_${self.fileName}.${self.suffix}`;
			},
			// changeFace() {
			// 	var self = this;
			// 	this.$refs.upload.submit();
			// },
			handleAvatarSuccess(res, file) {
				var self = this;
				file.url = `${self.qiniuaddr}/${res.key}`;
				var form = Qs.stringify({
					uuid: self.form.uuid,
					command: self.form.command,
					name: self.form.name,
					user_id: self.form.user_id,
					image_type: self.form.image_type,
					image_content: file.url,
					pass: self.form.pass
				})
				this.$axios.post('https://api.fengniaotuangou.cn/api/debug/device', form).then(res => {
					self.$message.success('发送成功');
					self.form.image_content = "";
					self.change_href = "";
					self.hasNewImage = false;
					self.resetForm2();
				})
			},
			//图片上传超过数量限制
			handleExceed(file, fileList) {
				var self = this;
				self.$message.error("上传图片不能超过1张!重新上传");
				self.$refs.upload.clearFiles();
				self.form.image_content = "";
				self.imgData.key = "";
			},

			getQiniuToken() {
				var self = this;
				this.$axios.get("https://api.fengniaotuangou.cn/api/upload/token").then(res => {
					self.imgData.token = res.data.uptoken;
				});
			},
		}
	}
</script>

<style scoped>
	.title {
		text-align: center;
		font-size: 28px;
		margin-bottom: 20px;
	}

	.box {
		/* width: 1500px; */
	}

	.upload-btn {
		margin-top: 10px;
	}

	.up-img {
		display: inline-block;
		margin: 0 50px;
	}

	.pic-box {
		max-width: 100%;
		height: 200px;
	}

	.tips {
		margin-bottom: 20px;
		color: red;
	}
</style>
